/*
 * GUIFactory.java
 *
 * Copyright 2007, 2008 Tiberiumlabs
 *
 * This file is part of Tiberiumlabs Lailaps.
 *
 * Tiberiumlabs Lailaps is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * Tiberiumlabs Lailaps is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.tiberiumlabs.lailaps.gui;

import java.awt.Dimension;
import java.awt.Insets;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.border.Border;

/**
 *
 * @author <a href="mailto:paranoid.tiberiumlabs@gmail.com">Paranoid</a>
 */
public class GUIFactory {

    // <editor-fold defaultstate="collapsed" desc=" components ">

    public static JPanel createVerticalBoxPanel() {
        JPanel panel = new JPanel();
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
        return panel;
    }

    public static JPanel createHorizontalBoxPanel() {
        JPanel panel = new JPanel();
        panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
        return panel;
    }

    private static final Insets INSETS = new Insets(0, 0, 0, 0);
    public static JButton createToolbarButton(Action action) {
        JButton result = new JButton(action);
        result.setOpaque(false);
        result.setBorderPainted(false);
        result.setHideActionText(true);
        result.setMargin(INSETS);
        return result;
    }

    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc=" borders ">

    private static Border emptyBorder = BorderFactory.createEmptyBorder(6, 6, 6, 6);
    public static Border createEmptyBorder() {
        return emptyBorder;
    }

    public static Border createTitledEmptyBorder(String title) {
        return BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(title), emptyBorder);
    }

    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc=" tools ">

    public static void setMaximumComponentHeight(JComponent component) {
        component.setMaximumSize(new Dimension(Short.MAX_VALUE, component.getPreferredSize().height));
    }

    // </editor-fold>

}
